package com.postracker.web.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.postracker.model.User;
import com.postracker.service.UserManagementService;
import com.postracker.web.bean.UserBean;

@Controller
@RequestMapping("/userManagement")
public class UserManagementController {

	private static final String BASE_FOLDER = "userManagement/";
	@Autowired
	private UserManagementService userManagementService;

	@RequestMapping(method = RequestMethod.GET)
	public String dbManagementPage() {
		return BASE_FOLDER + "userManagement";
	}

	@RequestMapping(value = "list", method = RequestMethod.GET)
	public @ResponseBody
	List<UserBean> list() {
		return userManagementService.getAllUsers();
	}

	@SuppressWarnings("unused")
	@RequestMapping(value = "createUser", method = RequestMethod.POST)
	public void createUser(HttpServletResponse response) {
		User user = new User();
		user.setName("name");
		user.setLogin("login");
		user.setId(Long.valueOf(123));
		// userList.add(user);
	}
}
